Quantitative, high-sensitivity measurement of liquid analytes using a smartphone compass

Smartphone ubiquity has led to rapid developments in portable diagnostics. While successful, such platforms are predominantly optics-based, using the smartphone camera as the sensing interface. By contrast, magnetics-based modalities exploiting the smartphone compass (magnetometer) remain unexplored, despite inherent advantages in optically opaque, scattering or auto-fluorescing samples. Here we report smartphone analyte sensing utilizing the built-in magnetometer for signal transduction via analyte-responsive magnetic-hydrogel composites. As these hydrogels dilate in response to targeted stimuli, they displace attached magnetic material relative to the phone’s magnetometer. Using a bilayer hydrogel geometry to amplify this motion allows for sensitive, optics-free, quantitative liquid-based analyte measurements that require neither any electronics nor power beyond that contained within the smartphone itself. We demonstrate this concept with glucose-specific and pH-responsive hydrogels, including glucose detection down to single-digit micromolar concentrations with potential for extension to nanomolar sensitivities. The platform is adaptable to numerous measurands, opening a path towards portable, inexpensive sensing of multiple analytes or biomarkers of interest.

1. Supplementary Notes: magnetometer-based smartphone sensor platform For data collection and initial testing and development, it was beneficial to be able to quickly adjust the fit of the attachment piece with shims so that the magnetic particles could be moved directly over the magnetometer for various iterations of the hydrogel actuator during development.We used many differently shaped attachment pieces including those shown in Supplementary Figs.1a and 1b.The prototype platform suggested in main paper Figs.1a and 1b represents a simplified, more compact version we envision for future use, where the attachment piece snaps snugly onto the phone without shims and with the magnetic particles of the hydrogel actuator automatically positioned directly over the magnetometer.The size and formulation of the hydrogel actuator would need to be standardized to use the type of assembly shown in the prototype.
Supplementary Figure 1: Magnetic hydrogel smartphone sensor platform used for data collection in this paper.(a) Schematic of the full assembly, including (i) lid, (ii) positioning clamp, (iii) hydrogel actuator, (iv) attachment piece with analyte well, and (v) smartphone.Shims are placed in between the attachment piece and the smartphone on the top and left sides to position the magnetic particles directly over the smartphone magnetometer.(b) Photograph of the assembled magnetometerbased smartphone sensor.
Adapting the magnetometer-based smartphone sensor to other smartphone models requires only changing the location of the analyte well to place the magnetic material over the magnetometer of the smartphone.As an example of a different phone, Supplementary Fig. 3 shows an attachment piece designed for a Google Pixel 2 smartphone.

Supplementary Notes: system characterization
To ascertain whether potential fluctuations in the background magnetic field might interfere with the sensor readings, two smartphones were used for data collection, one containing the full sensor platform (sensor phone) and one stationed nearby with no additional hardware (background phone).Both phones were calibrated to the background magnetic field before testing.Supplementary Figure 6 shows a sample of the raw data collected (from Fig. 2B, 20 mM reversibility cycle 2) during an experiment.The magnetic field reading, B, from the background phone (Supplementary Figure 6a) confirms that there is little change in the background magnetic field over the course of an experiment, with total fluctuations in the vector components Bx, By, Bz, and in Bt (the total field) each on the order of ~1 T or less.The magnetic field reading, B, of the sensor phone (Supplementary Figure 6b) shows that most of the change in magnetic field in response to 20 mM glucose is a result of sensor actuation is in the z-direction, with minimal changes in Bx and By.The change in Bt closely mirrors the change in Bz, which has a large negative value.This is expected since the embedded ensemble of Nd2Fe14B particles were magnetized axially and with negative z-direction pointed downward into the phone.The particles were magnetized axially instead of in-plane to maximize the magnetic field reading.The magnetic field reading of the background phone was subtracted from that of the sensor phone to obtain a background-subtracted signal where variations in the background magnetic field are controlled for (Supplementary Figure 6c).The signal of the magnetometer-based smartphone glucose sensor is generally considered to be the change in Bt from a 0 mM glucose baseline of the background-subtracted signal (Supplementary Figure 6d).In this work, Bx and By are negligible, making Bt approximately equal to Bz, and so from here on we refer to the signal of the magnetometer-based smartphone glucose sensor as Bz.While full background subtracted data is presented here for completeness, it should be noted that such background subtraction is only necessary in noisy magnetic environments.In practice there was never a substantial difference between the raw (sensor phone) and backgroundsubtracted data in any of the data reported in this report, and therefore only one phone is necessary for implementation of the magnetometer-based smartphone sensor.The reverse response of the hydrogel actuator (going from high glucose concentration to low glucose concentration) is slower than the forward response (0 to 20 mM).For each cycle, the magnetic field reading (B) was recorded in 0 mM glucose solution for 1 hour, changed to 20 mM glucose for 1 hour, then changed back to 0 mM glucose.The 0 mM glucose solution is then refreshed several times over several hours to return the magnetometer reading to its initial value (Supplementary Figure 7).Supplementary Figure 8 shows the Bz over three cycles of activation with 20 mM glucose.Solution changes are marked by brief downward spikes in the trendline, which occur due to the hydrogel actuator being pressed flat against the bottom of the well due to capillary forces in the absence of solution.Due to the high responsiveness of the sensor at low concentrations of glucose, thorough washing is required to return the magnetometer reading fully to baseline.Slow elastic relaxation of the hydrogel may also contribute to a slower reversible response of the sensor, even after all remnant glucose has been washed out, such as can be seen after the final wash step in cycle 3 (Supplementary Fig. 8c).While the low cost of the device allows for its use as a disposable test strip, this data shows that with further development (i.e.increased response time), the sensor has the potential for continuous monitoring applications.7: Full Reversibility data for glucose cycle 1.Several wash cycles are required to fully return the magnetometer-based glucose sensor signal to baseline.The sensor begins in a 0 mM glucose solution which is switched to 20 mM at time point (1).The solution is returned to 0 mM at time point (2) and this 0 mM solution is refreshed at timepoints (3) through ( 9) to account for any residual glucose that might not have been fully washed out during the prior steps.Source data are provided as a Source Data file.

Supplementary Figure
Supplementary Figure 8: Magnetometer-based glucose platform signal for the full reversibility test in (a) Cycle 1, (b) Cycle 2, (c) Cycle 3.For each cycle, the sensor reading was recorded in 0 mM glucose solution for 1 hour, changed to 20 mM glucose for 1 hour, then changed back to 0 mM glucose.The 0 mM glucose solution must be refreshed several times to return the magnetometer reading to its initial value.Differences in relaxation behavior back to baseline may be due to differences in when, and how thoroughly, wash steps were performed as well as due to potential diffusive mixing of possible remnant glucose in the test well, but once the sensor is back to baseline, it responds again reproducibly to the addition of glucose.Source data are provided as a Source Data file.Supplementary Figure 9 shows the change in field strength (Bz) in response to the three cycles of 20 mM glucose fit to a one-phase association curve, with GraphPad Prism Software version 9.4.0,Y0 is the y-intercept, Plateau is final value of the response, and k is a rate constant.Data before the inflection point in the response, seen at ~4.5 minutes in all three cycles, were excluded from the fit.This initial phase of the response is explained by the hydrogel resting on a bar placed toward the end of the bilayer section of the actuator while the bilayer is mostly flat in 0 mM conditions.This supporting bar was only necessary to prevent an initial response where the magnetometer reading decreased instead of increased, which occurred only in iterations of test hydrogel actuators where the initial curvature of the bilayer was slightly downward instead of flat or slightly upward.The slower initial phase of the response corresponds to the bilayer changing its curvature from downwards to upwards while being supported by the bar, and the accelerated rate of response after the inflection point at ~4.5 minutes corresponds to when the sensor has activated sufficiently such that it is no longer supported by the bar and is now freely travelling upwards and away from the phone surface through the 20 mM glucose test solution.The slope increases roughly 4x at this point, meaning a factor of four sensitivity is likely lost at the low end of the response, before the hydrogel actuator lifts off the bottom of the well.If the initial curvature of the bilayer is flat or slightly upwards, such as the iteration used in the future detection limit test, then the bar is not necessary (which should be the case for all future systems).Shims can also be used underneath the inert, horizontal section of the hydrogel actuator to raise it up so that the bilayer section does not rest on the bottom.In these cases, the response is single phase.
The response time (T90) was defined as the time it takes for Bz to reach 90% of the plateau value.
The T90 of the measured response to 20 mM glucose was determined to be 19.4,19.0, and 19.6 minutes for cycles 1, 2, and 3, respectively.The pH-responsive platform was characterized in terms of reversibility (Supplementary Fig. 10), reproducibility of the response (Supplementary Figs.11 and 12), and dose/response calibration (Fig. 3b in the main paper with supporting data in Supplementary Fig. 13).The pH hydrogel actuator is designed to lay flat in pH 4 solution.When the buffer is changed to pH 7, the bilayer portion of the hydrogel actuator curls and moves the Nd2Fe14B away from the magnetometer, increasing Bz.When the solution is changed back to pH 4, the bilayer flattens and the magnetometer reading returns to baseline, as shown in Supplementary Fig. 10.Here, the response of a single pH hydrogel actuator from pH 4 to 5 was tested 3x each on the Motorola Moto E (2020) and Google Pixel 2, alternating between the two, with the resulting response curves shown individually in Supplementary Figs.11a -S11f.Then, the response was again tested but with the Google Pixel 2 attachment piece affixed to the Moto E,but appropriately laterally shifted for different magnetometer placement in such a way that the magnetic field reading was maximized when the bilayer was flat.The hydrogel actuator was reset to baseline in pH 4 buffer before each trial, and shims were used underneath the inert clamping region of the actuator to adjust its position vertically, so that the baseline (pH 4) magnetometer value matched for each trial.A noisier signal is seen in the Google Pixel 2 trials, indicating that this (refurbished) phone model contained a noisier magnetometer than the one in the Moto E.

Supplementary
Supplementary Figure 12a shows the three response curves from the Moto E trials overlaid.The response is highly repeatable, with the standard deviation of the endpoint magnetometer response being just 0.56% of the total change in magnetic field reading.Supplementary Figure 12b shows the three response curves from the Google Pixel 2 trials overlaid.The response is also highly repeatable on this phone model, with the standard deviation of the endpoint magnetometer response being just 1.2% of the total change in magnetic field reading.The response is also reproducible between the phone models.Supplementary Figure 12c shows the 3 rd magnetometer response curve from both the Moto E and the Google Pixel 2, as well as the control trial where the Google Pixel 2 attachment piece was affixed to the Motorola Moto E. This plot shows that the shape of the response curve is only slightly different when using the Moto E vs. the Google Pixel 2. The control trial (yellow) matches the standard Motorola Moto E trial (orange), indicating that the difference in the shape of the response curves is due to a difference in the sensitivities of the two magnetometers at different points in space, rather than being an artifact of the different attachment pieces.Despite the difference in the shape of the response curves, the endpoint magnetometer readings are in good agreement.Supplementary Figure 12d shows the average and standard deviation of the endpoint magnetometer response for the three Moto E trials and the three Google Pixel 2 trials, with a difference of just 2.7 µT.This data shows that the response of the pH platform is also stable over at least 4 days (the duration over which these multiple experiments were performed) and many actuation and washing cycles.Supplementary Figure 14 shows that the response time of a hydrogel actuator is improved by adding Polyethylene Glycol 10,000 (PEG), serving as a pore-forming agent, to the precursor solutions for both the inert and active layers, as well as by making the active layer thinner.This was demonstrated on a pH-responsive hydrogel but could be applied to the glucose hydrogel actuator as well.Supplementary Figure 14a shows the raw field strength recording for pH hydrogels made with (red) and without (blue) PEG, and with both PEG and a thinner active layer (green), and the resulting response curve when the test solution is changed from pH 4 to pH 5, causing the actuators to curl from an initial flat state.The background-subtracted field strength is plotted rather than Bz to show that the response curves plateau at or above ~26 T, meaning that they are still well within range of the magnetometer.This was done to avoid response times of the hydrogel actuators that may appear artificially fast if the bilayers curl to a degree where the magnetic particles move out of range and the magnetometer reads ~0 T.The red, blue, and green curves start at different field strengths only because the different actuators had different initial offset distances from the base of the test fluid container and/or different magnetic particle loadings; this does not affect response time as can be seen in Supplementary Fig. 14b which shows the normalized response curves, clearly demonstrating the improved response time when PEG is added and/or the bilayer is made thinner.The T90 of these hydrogel actuators improves from approximately 47 minutes without PEG to approximately 23 minutes with PEG, and further to 13 minutes with both PEG and a thinner active layer, a roughly 2x improvement with each step.These results make the response time on par with an at-home COVID test, while further refinement should reduce it substantially further.
In Supplementary Figures 14c and 14d, we present an alternative method of signal transduction that could provide even faster, sub-minute measurements.Supplementary Figure 14c shows the standard sensor response to various pH levels, with a T90 on the order of 15 minutes before the signal stabilizes.Supplementary Figure 14d shows the same data but zoomed into the first 30 seconds.Taking either Bz after 30s or the initial slope of the response to be the sensor signal will still allow the user to discriminate between pH levels, even with additional noise introduced from the hydrogel settling after the solution change, as shown in Supplementary Fig. 14d.However, more characterization is necessary to determine the reproducibility, sensitivity, and dynamic range of these alternate, faster measurement methods.

Supplementary Notes: detection limit results
To probe the detection limit of the smartphone magnetometer-based sensor, Bz was recorded in response to five different concentrations of glucose, with 3 replicates each.For clarity, only three are shown in the main paper.Figure 3A is reproduced with error bars showing the range of Bz recorded over the three replicates in Supplementary Fig. 15a.Supplementary Figure 15b shows the average Bz for all five glucose concentrations recorded.The average Bz was calculated at the end of each run, between 119 and 120 minutes for each concentration to determine a calibration curve, shown in Supplementary Fig. 15c.A linear regression was applied to determine the response equation.An estimate of the limit of detection (LOD) is then determined at approximately 8 mM based on the formula LOD = 3.3 /S, where S is the slope of the fit equation (0.039) and  is the standard error of the Y-intercept determined from the linear regression (0.092).
While this single-digit micromolar limit of detection is reached for the current proof-of-concept, future optimization of the design should decrease this value substantially.
Supplementary Figure 15: Supplementary data for the detection limit test (Fig. 4a The regions are 100 seconds long and start 57 minutes after each solution change so that the sensor is closest to equilibrium with the test solution equilibrated.(e) The noise for the region corresponding to each glucose concentration, where SD represents the noise level (standard deviation of the residuals) and is determined by the process shown in Supplementary 16.Since the Nd2Fe14B particles move further away from the magnetometer with increasing glucose concentration, this data suggests that the noise level is not dependent on proximity of the Nd2Fe14B particles to the magnetometer and, hence, is unlikely due to any random fluctuations in those particles' field or in their spatial location and/or orientation as might occur due to vibration or other mechanical disturbances.The data also suggest that the noise is independent of the state of curl of the hydrogel actuator.Source data are provided as a Source Data file.

Magnetic field as a function of bilayer curvature
As noted in the main manuscript, for small deflections of the hydrogel bilayer, the embedded disk of magnetized particles translates essentially vertically above the phone magnetometer and the field measured at magnetometer scales linearly with the hydrogel fractional expansion (see main paper Equation 3).In this limit of small hydrogel deflection, the sensor is both most linear and at its highest sensitivity, and if potential ranges of analyte concentrations are known, the hydrogel bilayer system should ideally be designed to operate within this regime.
Supplementary Figure 18: Bilayer geometry.A flat (yellow), and subsequently curved bilayer of length L and thickness h, is shown sketched in the coordinate system used for all mathematical calculations in the paper.The end of the bilayer at the origin of the coordinate system is assumed fixed; the other end is free.The magnetization vector of the magnetized particles (black disk) at the free end of the bilayer strip is shown in red.A magnetometer chip buried below the end of the bilayer strip at depth Z0 within a cellphone (whose top surface lies at z = 0) is also shown.For clarity, the bending angle is exaggerated from what would apply during normal sensor operation.
However, larger hydrogel bilayer deflections are also possible (as seen, for example, in Supplementary Movie 1, in Figs.1e-1i and Supplementary Fig. 18).Larger deflections extend the dynamic range of the sensor but also lead to angular reorientations of the disk of magnetized particles, changing the direction of its magnetization with respect to the phone.Such deflections also cause not only vertical, but also horizontal, translations of the disk.For these larger deflections a calibration look-up table can be used to translate between field measurements and analyte concentrations, but it is also possible to analytically predict the field dependences even in these more complex situations, which for completeness we derive below.
The bending of thin bilayer beams due to differences in the expansion / shrinking of their two composite layers was first studied by Timoshenko [34] for the case of a bimetallic strip that bends when heated.Here we translate that work to the case of a hydrogel bilayer strip, clamped at one end and with magnetized particles embedded at the opposite free end, with the goal of quantifying how hydrogel expansions / contractions in response to targeted analytes change the magnetic field measured by a magnetometer located beneath the free end of the bilayer strip.We start by rewriting the general expression found in [34] for the bilayer curvature, 1/r, by replacing a difference in metallic thermal expansion factors with instead the fractional expansion, , of the active hydrogel layer in our bilayer strip to give: where h12 is the ratio of the top layer thickness h1 to the bottom layer thickness h2 in the bilayer strip, h = h1+h2 is the total bilayer thickness, and E12 is similarly the ratio of Young's moduli of the top and bottom layer materials (see Supplementary Fig. 18).For concreteness, the above assumes that only the active layer dilates, but if both layers dilate simultaneously the same analysis still applies, only with ε replaced by the difference in expansion factors for the two hydrogel layers.It is also assumed that the hydrogel bilayer is oriented such that curling draws the magnetized end up away from the phone, rather than pushing down into the phone.
For simplicity, we begin with a bilayer comprising two layers of equal thickness.This will not always be true, in which case the full equation above can be returned to, but starting with equal layer thicknesses significantly simplifies the above: Here we have also assumed equal Young's moduli for the two layers.Again, this is unlikely to be true but, as can be seen by substitution, even large differences in layer thicknesses or Young's moduli yield only small changes to the 3/2 prefactor.
Assuming homogeneous hydrogel material composition within each layer, and hence uniform hydrogel expansion along the length of the layers, the bilayer will always take the form of an arc of a circle with radius ρ given above.(This remains true even for flat layers with  = 0, where the circle has effectively infinite radius).As ε increases with increasing analyte concentration, the curvature increases and the hydrogel strip conforms to an increasing tighter arc of an increasing smaller circle.The opening angle  (in radians) of this arc formed by a bilayer of length L is then: Examples of the predicted bilayer curves are shown in Supplementary Fig. 19 for various  and overlaid for comparison on real world examples copied from main paper Fig. 1e-1i.
For small deflections,  remains small and substituting the Taylor expansions sin  ≈  and cos  ≈ 1 - 2 /2 into the above yields M = M•{ , 0, -1} and r = {0, 0, -L•  /2 -Z0}.That is, the magnetization continues to point primarily straight downwards towards the magnetometer and there is essentially zero motion in x and y with the magnetic particles being displaced primarily in the z-direction away from the magnetometer by a distance of L• /2.Taking  = 3 ε•L/2h from above, the displacement thus scales not simply proportionally to ε•L, as would be true for a single homogeneous strip of hydrogel but instead proportionally to 3ε•L 2 /4h, which constitutes a key advantage in using a bilayer hydrogel strip to enhance measurement sensitivity.
For these small deflections, which proceed primarily vertically and without any significant reorientation of the magnetization, the field from the disk-shaped collection of magnetized particles takes a simple analytic form, given by Equation 1 in the main paper.For larger motions of the hydrogel bilayer, however, the magnetometer no longer continues to lie along the axis of the disk; nor does the disk magnetization M point directly towards the magnetometer, invalidating the use of the simple on-axis circular current loop model used.At these larger distances, however, the field from the disk of particles can be well approximated with a simpler, spherical collection of particles, whose vector magnetic field B at position r relative to the center of that sphere is equivalent to that from a point magnetic dipole and given by: where µ0 is the vacuum permeability and m is the total magnetic moment, and  ̂ is the unit displacement vector.Or, rewritten in terms of an actual sphere of finite radius Rsphere with magnetization per unit volume, Substituting for the vectors M and r from Equations S5 and S6, then yields general expressions for all three vector components of the magnetic field at the location of the magnetometer that remain valid for arbitrarily large curlings of the hydrogel bilayer: The measured field at the magnetometer can then be determined in terms of the fractional hydrogel expansion ε, which itself depends on the analyte concentration being tested, by substituting either the simple expression  = ε•(3L/2h), or by starting from the more complete expression in Equation S1, as appropriate.
While the above is valid for any , it is instructive to compare its behavior for small  with that for the diskshaped magnet given in the main paper.Taylor expanding the above for small  gives: As detailed in the main paper, for small displacements Δz, the change in field is ∆ = ( ) • ∆ ⁄ which now in terms of  becomes ∆ = (  ⁄ ) • (  ⁄ ) • ∆.As shown above, for small  the z-position of the magnet is described by z ≈ L•  /2, giving   ⁄ = 2/.Taking ∆ = 3 2 /4ℎ, then yields: To facilitate better comparison with disk-shaped magnets, the total magnetic moments of sphere and disk can be matched by equating their volumes via  ℎ 3 = 3  2  4 ⁄ , where d was the disk thickness.Note that in the limit   ≪  0 , where from the vantage point of the magnetometer the disk arrangement of magnetic particles becomes indistinguishable from a spherical one, ΔBz becomes identically equivalent to that of Equation 2 in the main paper, as expected.Alternatively, setting   = √2/3 •  0 (as detailed in the main paper), and substituting into the above yields: As expected, this has the same form as Equation 3 in the main paper, only with a different numerical prefactor owing to the spherical, rather than disk-shaped, magnetic particle distribution.Interestingly, while the current work used a disk-shaped magnetic particle ensemble (because it was simplest to fabricate), comparing the above with Equation 3shows that arranging the same quantity of magnetic particles into a sphere, rather than a disk, could in the future enhance sensor sensitivity a further 3-fold.

Range of validity of on-axis disk field model (main paper Equation 1)
While the above gives general field expressions for arbitrary bilayer curling, the simpler on-axis disk field model presented in the main paper can be applied over a large portion of the sensor's dynamic range, as shown here.
Equation 1 in the main paper, reproduced here for the field at a distance z + Z0 away from the center of a magnetized disk of magnetization M, radius R, and thickness d, is given by: Substituting in the optimal disk radius defined in the paper,  = √2 3 ⁄ •  0 , gives: which represents a field that rapidly decays in space.Basic rearrangement shows that Bz(z) falls to 1/n of its initial value, Bz(z=0), when  = (√(5 2 3 ⁄ − 2)/3 − 1) •  0 .For example, Bz(z) falls to one half of its initial value at a distance of z = 0.4Z0 above the surface of the phone.That is, for a magnetometer embedded at a depth z0 of around 3 to 5 mm beneath the surface of the phone, the field can be made to drop by 50% by raising the disk magnet's z-position just 1 to 2 mm above the phone surface.Assuming even a relatively short hydrogel bilayer strip with L = 20 mm, this corresponds to a change in orientation angle of the plane of the disk of order 5 to 10 degrees from horizontal and a shift in the magnet's x-position of no more than 0.1 mm, as can both be determined through use of Equation S4.At 0.1 mm, this lateral shift is both far smaller than the size of the magnetic disk and negligible compared to the disk's z-translation.Meanwhile, the 5-to-10-degree reorientation of the magnetization direction yields less than a 2 percent reduction in the Bz field component, which scales with the cosine of the reorientation angle.That is, over at least half of the sensor's dynamic range, the simple model of a disk translating purely vertically without any reorientation, as given in Equation 1, remains a good approximation.
Equivalent analysis shows that even a 75% field reduction still leads to a mostly negligible 0.5 mm lateral shift in position, albeit this time of order 20-degree reorientation corresponding to or order 10% decrease in the Bz field component.While still not a large error now over even a full ¾ of the sensor dynamic range, good approximation can still be achieved with the horizontally oriented on-axis disk model of Equation 1 by adding a cos correction factor to better account for the (slightly) changed Bz field projection.Recasting Equation 1 then in terms of , recalling that  = (1 − cos ) • (  ⁄ ) from Equation S4, gives the more complex, but more accurate approximation: Or, substituting  = 3 2ℎ ⁄ from Equation S3 then yields the measured Bz field at the magnetometer directly in terms of the hydrogel fractional expansion, ε:

Comparison of bilayer vs monolayer
Comparing the above to that which would result from a monolayer gel, helps quantify the advantage of a bilayer hydrogel geometry.We perform this analysis here for monolayers oriented both horizontally (like the bilayer) and vertically above the phone surface, as shown schematically in Supplementary Fig. 21.

i) Horizontally oriented monolayer
If the above bilayer is replaced by a simple (monolayer) hydrogel, positioned identically to the bilayer above the phone and with a length that scales with the same fractional hydrogel expansion ε as the active layer in the above bilayer, then Equation S4 above can be rewritten for the position of the magnetized particles in a single layer system as: {, , } = {(1 + ), 0 , 0} (S17) with the position of the magnetometer relative to the magnetized particles now being described by the displacement vector: Since expansion/contraction of a single homogeneous layer involves no change in curvature or angular orientation, Equation S5 for the vector magnetization, M, of the disk, simplifies to: Substituting into Equation S8, then yields general expressions for the magnetic field at the location of the magnetometer, this time due to an expanding single hydrogel layer: which for small ε become:

Supplementary Tables: Cost estimates
Supplementary

Synthesis of Glucose Hydrogel Actuators.
A 'T' shaped poly-dimethylsiloxane (PDMS) well was first created and then used as a mold to form the glucose hydrogel actuators.The top, horizontal segment was 12 mm in width, 4 mm in height, and 0.5 mm in depth and the bottom, vertical segment was 10 mm in height, 4 mm in width, and 0.5 mm in depth.Corners were rounded to reduce any potential stress buildup in the hydrogel shape.A thin, 0.05 mm tall bar protruding from the bottom of the well was used to separate the horizontal segment from the vertical segment.24 mL of inert hydrogel precursor was placed in the top, horizontal segment of the well and pinned to the walls of the well and the separating bar via naturally occurring capillary wetting forces.20 mL of glucoseresponsive precursor was spread on the vertical segment and similarly pinned to the walls and gently connected to the inert precursor in the horizontal segment.The bottom layer was then partially cured under UV light (365 nm, 4W) with N2 gas flowing for 40 seconds.Then, 2 mg of silica-coated Nd2Fe14B particles were mixed into 22 mL of inert precursor and deposited on top of an immobilized magnet, placed directly beneath the PDMS well, to magnetically attract the particles into a disc shape near the tip of the vertical arm, before spreading the liquid inert precursor to the walls of the well along the T-shape.Due to shrinkage of the bottom layer during curing, the same well walls were used to pin both the top and bottom layers.Both layers were then fully cured and bonded under UV light (365 nm, 4W) with N2 gas flowing for 10 minutes.

Synthesis of pH Hydrogel Actuators.
A similar 'T'-shaped PDMS well was used to form the pH hydrogel actuators.The top, horizontal segment was 16.5 mm in width, 5.5 mm in height, and 0.5 mm in depth and the bottom, vertical segment was 15 mm in height, 5.5 mm in width, and 0.5 mm in depth.Corners were rounded to reduce any potential stress buildup in the hydrogel shape.Due to a difference in degree of initial swelling when placed in solution after curing, pH hydrogel actuators were synthesized in larger wells to achieve similar sized structures to the glucose counterparts.110 mL of inert hydrogel was placed in the well and pinned to all edges of the 'T' shape before partially curing under UV light (365 nm, 4W) with N2 gas flowing for 20 seconds.Then, 2 mg of silica coated Nd2Fe14B particles were mixed into 10 mL of pH hydrogel precursor and deposited on top of an immobilized magnet, placed directly beneath the PDMS well, to magnetically attract the particles into a disc shape near the tip of the vertical arm, before pinning the pH hydrogel precursor to the edges along the vertical segment of the well only.Both layers were then fully cured and bonded under UV light (365 nm, 4W) with N2 gas flowing for 5 minutes.
Smartphone data collection.Two smartphones were typically used for data collection; one with the sensor platform attached (sensor phone) and a second smartphone that was placed near nearby and with no attachments to control for potential variations in background magnetic field (background phone).Magnetometer data was collected on both the sensor phone and background phone using Physics Toolbox Pro app for all experiments, with initial calibration to subtract off Earth's background field.All other apps, internet, Bluetooth, and other phone functions were turned off during testing to prevent CPU usage from affecting the magnetometer readings 1 .A backgroundsubtracted Bt was then determined with the formula   = √  2 +   2 +   2 , where Bx, By, and Bz are the background-subtracted field readings (sensor phone reading minus control phone reading) in the x, y, and z directions.Although background subtraction was always performed, it was found empirically to almost never be needed, not making any significant difference to the data unless there was a significant external magnetic event during data collection (which happened only rarely and only when doing very long runs over many hours).

Detection Limit Testing.
A single glucose hydrogel actuator was used to collect the data shown in Fig. 3A.For each experiment, the hydrogel actuator was given four hours to equilibrate in 5 mL of HEPES/NaOH buffer, pH 7.4, with 0 mM glucose.Then, a small amount of HEPES/NaOH buffer, pH 7.4, with 2 mM glucose was added to the test solution (12.5 mL, 18.8 mL, 25.1, or 50.4 mL) to raise the total glucose concentration to the desired levels (5 mM, 7.5 mM, 10 mM or 20 mM, respectively), followed by gently mixing the solution with a 2 mL transfer pipette to achieve a uniform

Figure 3 :
Picture of a version of the plastic attachment piece designed for the Google Pixel 2. Supplementary Figure 5: Control of the initial, analyte-free curvatures of the glucose hydrogel actuators after swelling to equilibrium in pH = 7.4 buffer with 0 mM glucose by using inert layers containing (a) 80 L, (b) 70 L, (c) 60 L, (d) 50 L, and (e) 40 L of DMA.Varying the content of DMA in the inert layer compared to the smart hydrogel layer allows the bilayer to lay flat for any chosen initial analyte concentration.

Figure 6 :
Determination of the magnetometer-based smartphone sensor signal.Raw magnetometer readings (b) collected from 3-axis magnetometer in the (a) background phone, (b) test phone, and (c) the resulting background-subtracted sensor signal.(d) The signal of the magnetometer-based smartphone glucose sensor is generally considered to be the change in field strength of the background-subtracted total field strength (Bz) from the 0 mM glucose baseline.Source data are provided as a Source Data file.

Figure 9 :
Response time of the same glucose hydrogel actuator to 20 mM glucose for (a) Cycle 1, (b) Cycle 2, and (c) Cycle 3. Source data are provided as a Source Data file.Supplementary Figure 10: Response of the pH hydrogel actuator between pH 4 and pH 7 buffers.

Supplementary Figure 11 :
Reproducibility of response for the pH sensor platform and phone model comparison.The response (Bz) of a single pH hydrogel actuator, from pH 4 to pH 5 buffer, alternating between testing on (a, c, e) the Motorola Moto E (2020) and (b, d, f) the Google Pixel 2 over 4 days.(g) The response (Bz) of the same pH hydrogel actuator, from a pH 4 buffer to a pH 5 buffer, on the Moto E but using the Google Pixel 2 attachment piece.Source data are provided as a Source Data file.Supplementary Figure 12: Summary of pH hydrogel reproducibility.(a) Response of the pHresponsive hydrogel actuator on a Motorola Moto E from pH 4 to pH 5 buffer for three trials (data shown individually in Supplementary Figs.11 a, c, and e).(b) Response of the pH-responsive hydrogel actuator on a Google Pixel 2 from pH 4 buffer to pH 5 buffer for three trials (data shown individually in Supplementary Figs.11 b, d, and f).(c) Comparison of the 3 rd Moto E trial, the 3 rd Google Pixel 2 trial, and the Moto E response using the Google Pixel 2 attachment piece, showing that the response curve of the Moto E using the Google Pixel 2 attachment matches the response curve of the other Moto E trials rather than the other Google Pixel 2 trials.(d) Average endpoint magnetometer response from pH 4 to pH 5 buffer on the Moto E, vs the Google Pixel 2. Source data are provided as a Source Data file.
) in the main paper.(a) The average Bz over time in response to different glucose concentration levels (labeled), and with error bars showing the range of Bz recorded over three replicates for each concentration.(b) Full experimental data collected for detection limit testing, showing the average Bz over time in response to five concentrations of glucose.(c) Calibration curve showing the average Bz between 119 and 120 minutes in Supplementary Fig. 15b for the five glucose concentrations tested and fit with a linear trend.Source data are provided as a Source Data file.Supplementary Figure 16: Supplementary data for the noise analysis in Fig. 4b.On three different smartphones of the same model, the magnetometer was recorded for one hour without any sensor platform attached followed by one hour with the sensor platform attachment, with sample data from phone A shown here.(a) The z-direction field strength (Bz) as recorded by the magnetometer over the two-hour window, showing ten different 100-second-long regions where the noise of the system is interrogated, five before and five after the sensor platform attachment is added.(b-k) A linear trend is first fit to the data in each individual region to eliminate to first order any potential long-term background drift and then the noise level (standard deviation of the residuals, SD) is determined based on the formula SD = √∑ residual   , where n is the number of data points.Source data are provided as a Source Data file.Supplementary Figure 17: Evaluation of noise from the dose/response data in Fig. 2b.(a) Raw magnetometer data from the sensor phone as the test solution is cycled through 0 mM, 10 mM, 31.6 mM, 100 mM, 316 mM, 1 mM, 3.16 mM, 10 mM, 31.6 mM, and 100 mM glucose for one hour each.(b-d) Raw magnetometer data from the sensor phone with regions labeled for noise analysis.